package com.jt.controller;

import com.jt.pojo.Rights;
import com.jt.service.RightsService;
import com.jt.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Shining star
 * @create 2021-08-05-14:29
 */
@RestController
@CrossOrigin
@RequestMapping("/rights")
public class RightsController {

    @Autowired //不写会报空指针异常
    private RightsService rightsService;

    @RequestMapping("/getAll")   //localhost:8060/rights/getAll
    public List<Rights> getAll() {
        return rightsService.getALL();
    }

    /*需求: 查询2级菜单结构,并且封装为List集合
     *请求路径  /rights/getRightsList
     *请求类型  GET
     * 请求参数 无
     * 响应数据 SysResult对象(list集合)
     */
    @GetMapping("/getRightsList")    //localhost:8060/rights/getRightsList
    public SysResult getRightsList() {
        List<Rights> rightsList = rightsService.getRightsList();
        return  SysResult.success(rightsList);
    }

}
